package server.handler.groupHandler;

import com.alibaba.fastjson.JSONObject;
import common.EnvelopeMessage;
import server.dao.GroupDao;
import server.handler.SimpleHandler;
import server.session.Session;

import java.util.List;

public class GroupMutedListHandler implements SimpleHandler {
    @Override
    public void handle(EnvelopeMessage msg, Session session) {
        JSONObject body = msg.getBody();
        Integer groupId = body.getInteger("groupId");
        List<String> mutedMembers = new GroupDao().getMutedMembers(groupId);
        JSONObject object = new JSONObject();
        object.put("mutedList",mutedMembers);
        EnvelopeMessage back = new EnvelopeMessage("group","mutedList",object);
        String json = JSONObject.toJSONString(back);
        System.out.println("服务端返回"+json);
        session.send(json);
    }
}
